package org.jprobe.classpath;

import java.io.File;
import java.io.IOException;
import java.util.Set;
import java.util.jar.JarFile;
/**
 * classpath reader specifications
 * @author Hussain Al-Mutawa
 * @version 1.0
 * @since 1.0
 */
public interface ClassPathReaderInterface {
	/**
	 * loads the packages in a given directory
	 * @param directory the project directory
	 * @return set of parent classes
	 * @throws IOException if the path is invalid
	 * @return set of packages read from the classpath
	 */
	Set<String> loadPackages(final File directory) throws IOException;
	/**
	 * loads the java runtime library packages from
	 * <code>./JAVA_HOME/jre/lib/rt.jar</code>
	 * @throws IOException if the path does not exist or the archive is not readable
	 */
	void loadJavaRuntimeLibraryPackages() throws IOException;
	/**
	 * loads jar entries (classes) and store them in the map
	 * @param jarPath the path of the jar archive
	 * @throws IOException if the path is incorrect
	 *
	 */
	Set<String> loadPackages(JarFile jar) throws IOException;
	/**
	 * adds a class name to the class path entries
	 * @param classEntry a class entry
	 * @param path the path from which the class can be loaded using URLCLassLoader
	 */
	void addClassToCLASSPATH(ClassEntryInterface classEntry);
	/**
	 * gets the classpath instance
	 * @return the classpath associated with this classpath reader
	 */
	ClassPathInterface getClassPath();
	/**
	 * adds a url to the class loader, and updates the populated records in the CLASSPATH
	 * using the default ClassPathReader
	 * @param file path to classpath entry
	 * @throws Exception if the url is invalid or does not exist
	 * @return list of packages read from the classpath
	 */
	String[] addClassPathUrlToSystemClassLoader(final File file) throws Exception;
	/**
	 * adds a url to the class loader, and updates the populated records in the CLASSPATH
	 * using the default ClassPathReader
	 * @param file path to classpath entry
	 * @throws Exception if the url is invalid or does not exist
	 * @return list of packages read from the classpath
	 */
	String[] addClassPathUrlToSystemClassLoader(String path) throws Exception;
	/**
	 * removes an entry from the classpath
	 * @param path the classpath entry, must be a valid URI
	 * @throws Exception if removing the resource has failed
	 */
	void removeClassPathUrlFromSystemClassLoader(String path) throws Exception;
}